package com.oocl.euc.core.builder;

import com.oocl.euc.core.maintenance.model.FunctionAuth;
import com.oocl.euc.core.maintenance.model.Role;
import com.oocl.euc.core.maintenance.model.Status;
import com.oocl.euc.core.maintenance.repository.FunctionAuthRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class FunctionAuthBuilder {

    private FunctionAuth functionAuth;

    @Autowired
    private FunctionAuthRepository functionAuthRepository;

    public FunctionAuthBuilder defaultBuilder() {
        this.functionAuth = new FunctionAuth();
        return this;
    }

    public FunctionAuthBuilder withStatus(Status status) {
        this.functionAuth.setStatus(status);
        return this;
    }

    public FunctionAuthBuilder withRole(Role role) {
        this.functionAuth.setRole(role);
        return this;
    }

    public FunctionAuth create(){
        return functionAuth;
    }

    public FunctionAuth saveToDB(){
        functionAuthRepository.save(functionAuth);
        return functionAuth;
    }
}
